<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\User;

class Order extends Model
{
    use SoftDeletes;
    public static $type = ['0'=> '线上', '1' => '线下'];
    public static $status = ['0'=> '待确认', '1' => '待付款', '2' => '待发货', '3' => '待收货', '4' => '已完成'];

    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    public function orders_goods()
    {
        return $this->hasMany(OrdersGood::class, 'orders_id', 'id');
    }

    public function address(){
        return $this->hasOne(Address::class, 'id', 'address_id');
    }

    public function getStatusesAttribute($val)
    {
        return static::$status[$this->status];
    }
}
